<template>
  <zh-form-card title="基本信息" :span="24">
    <zh-form ref="formRef" :model="data.formData" label-width="200px" :span="12" :rules="data.rules">
            <zh-form-input
          prop="sfzh"
          label="证件号码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.sfzh"
      ></zh-form-input>
      <zh-form-input
          prop="xm"
          label="姓名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.xm"
      ></zh-form-input>
      <zh-form-input
          prop="mzdm"
          label="民族代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.mzdm"
      ></zh-form-input>
      <zh-form-input
          prop="mz"
          label="民族名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.mz"
      ></zh-form-input>
      <zh-form-input
          prop="xbdm"
          label="性别代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.xbdm"
      ></zh-form-input>
      <zh-form-input
          prop="xb"
          label="性别名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.xb"
      ></zh-form-input>
      <zh-form-input
          prop="czztdmlx"
          label="持证主体代码类型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.czztdmlx"
      ></zh-form-input>
      <zh-form-input
          prop="qzrq"
          label="签注日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.qzrq"
      ></zh-form-input>
      <zh-form-input
          prop="qzdqrq"
          label="签注到期日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.qzdqrq"
      ></zh-form-input>
      <zh-form-input
          prop="zjztdm"
          label="证件状态代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.zjztdm"
      ></zh-form-input>
      <zh-form-input
          prop="zjzt"
          label="证件状态名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.zjzt"
      ></zh-form-input>
      <zh-form-input
          prop="zjnbbh"
          label="居住证内部编号"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.zjnbbh"
      ></zh-form-input>
      <zh-form-input
          prop="xzqhdm"
          label="所属区划编码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.xzqhdm"
      ></zh-form-input>
      <zh-form-input
          prop="xzqhmc"
          label="行政区划名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.xzqhmc"
      ></zh-form-input>
      <zh-form-input
          prop="jzdz"
          label="居住地址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.jzdz"
      ></zh-form-input>
      <zh-form-input
          prop="kpbh"
          label="卡片编号"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.kpbh"
      ></zh-form-input>
      <zh-form-input
          prop="fzrq"
          label="发证日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fzrq"
      ></zh-form-input>
      <zh-form-input
          prop="zxrq"
          label="注销日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.zxrq"
      ></zh-form-input>
      <zh-form-input
          prop="zxyydm"
          label="注销原因代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.zxyydm"
      ></zh-form-input>
      <zh-form-input
          prop="zxyy"
          label="注销原因名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.zxyy"
      ></zh-form-input>
      <zh-form-input
          prop="hksxdm"
          label="户口省县代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hksxdm"
      ></zh-form-input>
      <zh-form-input
          prop="hksx"
          label="户口省县名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hksx"
      ></zh-form-input>
      <zh-form-input
          prop="hjdz"
          label="户籍地址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hjdz"
      ></zh-form-input>
      <zh-form-input
          prop="fzjgTyxydm"
          label="签发机关统一社会信用代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fzjgTyxydm"
      ></zh-form-input>
      <zh-form-input
          prop="dscCity"
          label="所属地市"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscCity"
      ></zh-form-input>
      <zh-form-input
          prop="dscAdmRegion"
          label="所属区/县"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscAdmRegion"
      ></zh-form-input>
      <zh-form-input
          prop="fzdgajg"
          label="发证地公安机关名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fzdgajg"
      ></zh-form-input>
      <zh-form-input
          prop="fzdgajgdm"
          label="签发机关代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fzdgajgdm"
      ></zh-form-input>
      <zh-form-input
          prop="dscSydepTblname"
          label="数源单位表名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscSydepTblname"
      ></zh-form-input>
      <zh-form-input
          prop="dscDatasrTblname"
          label="数据来源表名(清洗库或基础库 表名)"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscDatasrTblname"
      ></zh-form-input>
      <zh-form-input
          prop="dscDwRksj"
          label="地市仓数据入库时间"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscDwRksj"
      ></zh-form-input>
      <zh-form-input
          prop="dscHashUnique"
          label="业务主键MD5值（清洗增加）"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscHashUnique"
      ></zh-form-input>
      <zh-form-input
          prop="dscCleanTimestamp"
          label="清洗时间（清洗增加）"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscCleanTimestamp"
      ></zh-form-input>
      <zh-form-input
          prop="dscSydepName"
          label="数源单位"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscSydepName"
      ></zh-form-input>
      <zh-form-input
          prop="dscSydepSys"
          label="数据所属系统名称"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscSydepSys"
      ></zh-form-input>
      <zh-form-input
          prop="dscSydepCode"
          label="数源单位代码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscSydepCode"
      ></zh-form-input>
      <zh-form-input
          prop="dscBizOperation"
          label="I 插入 U 更新 D 删除"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.dscBizOperation"
      ></zh-form-input>
      <zh-form-input
          prop="year"
          label="年份"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.year"
      ></zh-form-input>
      <zh-form-input
          prop="areaCode"
          label="行政区划"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.areaCode"
      ></zh-form-input>
      <zh-form-input
          prop="materials"
          label="佐证材料"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.materials"
      ></zh-form-input>
      <zh-form-input
          prop="sourceType"
          label="数据来源：1 大数据获取 2管理员录入 3 学校录入"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.sourceType"
      ></zh-form-input>
      <zh-form-input
          prop="authStatus"
          label="审核状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.authStatus"
      ></zh-form-input>
    </zh-form>
  </zh-form-card>
</template>

<script lang="ts" setup name="eduLivePlaceOfflineForm">
import { ElMessage } from 'element-plus';

//------------------定义子组件---------------------------
const formRef = ref();
//------------------接收传入参数(组件)-------------------
const props = defineProps({
  livePlaceId: {
    type: String,
    default: '',
  },
  disabled: {
    type: Boolean,
    default: true,
  },
  btnLoding: Boolean,
});
const emits = defineEmits(['update:btnLoding', 'canner', 'refreshTable']);
//------------------初始化------------------------------
onMounted(() => {
  getDict();
  getsurveyInfo();
});
//------------------内部变量定义-------------------------
const data = reactive({
  formData: {} as any,
  detailVisible: true,
  loading: false,
  rules: {
  },
  dictData: {} as any,
  areaCodeDict: [] as any,
  campusParam: {} as any,
});

// 查询数据字典信息
const getDict = () => {
  const params = {} as any;
  params.dictFields = '';
  $api.common.getBatchDict.post(params).then((res) => {
    data.dictData = res.result;
  });
};

//获取详情
const getsurveyInfo = () => {
  if (!props.livePlaceId) {
    return;
  }
  data.loading = true;
  $api.common.send
  .post('eduLivePlaceOffline0002', { livePlaceId: props.livePlaceId })
  .then((res: any) => {
    data.formData = res.result || {};
    data.loading = false;
    data.campusParam.schoolId = data.formData.schoolId;
  })
  .catch(() => {
    data.loading = false;
  });
};

//保存
async function saveBase() {
  let checkFlag = await formRef.value.checkForm();
  if (checkFlag) {
    if (data.formData.livePlaceId) {
      $api.common.send
      .post('eduLivePlaceOffline0005', data.formData)
      .then(() => {
        ElMessage.success('修改成功');
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = false));
        emits('refreshTable');
      })
      .catch(() => {
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = true));
      });
    } else {
      $api.common.send
      .post('eduLivePlaceOffline0004', data.formData)
      .then(() => {
        ElMessage.success('新增成功');
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = false));
        emits('refreshTable');
      })
      .catch(() => {
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = true));
      });
    }
  }
}

//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({ saveBase });
</script>
<style lang="scss" scoped></style>
